package com.business.api.official.toursism.websiteimage.manager.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.business.api.official.toursism.websiteimage.manager.WebsiteImageApiManager;
import com.business.api.official.toursism.websiteimage.mapper.WebsiteImageApiMapper;
import com.business.api.official.toursism.websiteimage.vo.WebsiteImageApiBriefListVO;
import com.business.api.official.toursism.websiteimage.vo.WebsiteImageApiBriefVO;
import com.business.api.official.toursism.websiteimage.vo.WebsiteImageApiDetailListVO;
import com.business.api.official.toursism.websiteimage.vo.WebsiteImageApiDetailVO;
import com.business.api.official.toursism.websiteimage.vo.data.WebsiteImageApiBriefData;
import com.business.api.official.toursism.websiteimage.vo.data.WebsiteImageApiDetailData;
import com.business.system.official.toursism.websiteimage.entity.WebsiteImage;
import com.business.system.official.toursism.websiteimage.manager.WebsiteImageManager;
import com.seed.core.exception.ManagerException;
import com.seed.core.pojo.manager.impl.SeedApiManagerImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 轮播图
 * @author CodeGenerator
 * @date   2025-01-27
 * @version V1.0
 */
@Slf4j
@Service("websiteImageApiManager")
@Transactional(rollbackFor = ManagerException.class)
public class WebsiteImageApiManagerImpl extends SeedApiManagerImpl<WebsiteImageApiMapper, WebsiteImage> implements WebsiteImageApiManager {
    @Autowired
    private WebsiteImageManager systemManager;

    /**
     * 根据id获取详情VO data
     *
     * @param websiteImageId 对象id
     * @return 详情VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailData convertApiDetailData(String websiteImageId) throws ManagerException {
        WebsiteImage websiteImage = this.getById(websiteImageId);
        return this.convertApiDetailData(websiteImage);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImage model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailData convertApiDetailData(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageApiDetailData websiteImageApiDetailData = new WebsiteImageApiDetailData();
        try {
            BeanUtils.copyProperties(websiteImage, websiteImageApiDetailData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteImage);
        }
        return websiteImageApiDetailData;
    }

    /**
     * 根据id获取详情VO
     *
     * @param websiteImageId 对象id
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailVO getApiDetailVO(String websiteImageId) throws ManagerException {
        WebsiteImageApiDetailData websiteImageApiDetailData = this.convertApiDetailData(websiteImageId);
        return new WebsiteImageApiDetailVO(websiteImageApiDetailData);
    }

    /**
     * 根据对象获取详情VO
     *
     * @param websiteImage 对象
     * @return 详情VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailVO getApiDetailVO(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageApiDetailData websiteImageApiDetailData = this.convertApiDetailData(websiteImage);
        return new WebsiteImageApiDetailVO(websiteImageApiDetailData);
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageApiDetailData> getConvertApiDetailListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteImage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteImage::getId, ids);
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteImageList);
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageApiDetailData> listConvertApiDetailData(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertApiDetailData(websiteImageList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImageList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageApiDetailData> listConvertApiDetailData(List<WebsiteImage> websiteImageList) throws ManagerException {
        List<WebsiteImageApiDetailData> websiteImageApiDetailDataList = new ArrayList<>();
        for (WebsiteImage websiteImage : websiteImageList) {
            websiteImageApiDetailDataList.add(this.convertApiDetailData(websiteImage));
        }
        return websiteImageApiDetailDataList;
    }

    /**
     * 根据对象ids获取详情VO data list
     *
     * @param ids 对象ids
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailListVO getApiDetailListVOByIds(List<String> ids) throws ManagerException {
        return new WebsiteImageApiDetailListVO(this.getConvertApiDetailListVOByIds(ids));
    }

    /**
     * 根据查询条件获取详情VO data list
     *
     * @param queryWrapper 查询条件
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailListVO getApiDetailListVO(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        return new WebsiteImageApiDetailListVO(this.listConvertApiDetailData(queryWrapper));
    }

    /**
     * 根据对象list获取详情VO data list
     *
     * @param websiteImageList 对象list
     * @return 详情VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiDetailListVO getApiDetailListVO(List<WebsiteImage> websiteImageList) throws ManagerException {
        return new WebsiteImageApiDetailListVO(this.listConvertApiDetailData(websiteImageList));
    }

    /**
     * 根据id获取简略VO data
     *
     * @param websiteImageId 对象id
     * @return 简略VO data对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefData convertApiBriefData(String websiteImageId) throws ManagerException {
        WebsiteImage websiteImage = this.getById(websiteImageId);
        return this.convertApiBriefData(websiteImage);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImage model
     * @return VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefData convertApiBriefData(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageApiBriefData websiteImageApiBriefData = new WebsiteImageApiBriefData();
        try {
            BeanUtils.copyProperties(websiteImage, websiteImageApiBriefData);
        } catch (Exception e) {
            throw new ManagerException(e, websiteImage);
        }
        return websiteImageApiBriefData;
    }

    /**
     * 根据id获取简略VO
     *
     * @param websiteImageId 对象id
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefVO getApiBriefVO(String websiteImageId) throws ManagerException {
        WebsiteImageApiBriefData websiteImageApiBriefData = this.convertApiBriefData(websiteImageId);
        return new WebsiteImageApiBriefVO(websiteImageApiBriefData);
    }

    /**
     * 根据对象获取简略VO
     *
     * @param websiteImage 对象
     * @return 简略VO对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefVO getApiBriefVO(WebsiteImage websiteImage) throws ManagerException {
        WebsiteImageApiBriefData websiteImageApiBriefData = this.convertApiBriefData(websiteImage);
        return new WebsiteImageApiBriefVO(websiteImageApiBriefData);
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageApiBriefData> listConvertApiBriefDataByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteImage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteImage::getId, ids);
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteImageList);
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageApiBriefData> listConvertApiBriefData(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return this.listConvertApiBriefData(websiteImageList);
    }

    /**
     * 转换为VO对象
     *
     * @param websiteImageList model列表
     * @return VO对象列表
     * @throws ManagerException 通用层异常
     */
    @Override
    public List<WebsiteImageApiBriefData> listConvertApiBriefData(List<WebsiteImage> websiteImageList) throws ManagerException {
        List<WebsiteImageApiBriefData> websiteImageApiBriefDataList = new ArrayList<>();
        for (WebsiteImage websiteImage : websiteImageList) {
            websiteImageApiBriefDataList.add(this.convertApiBriefData(websiteImage));
        }
        return websiteImageApiBriefDataList;
    }

    /**
     * 根据对象ids获取简略VO data list
     *
     * @param ids 对象ids
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefListVO getApiBriefListVOByIds(List<String> ids) throws ManagerException {
        LambdaQueryWrapper<WebsiteImage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(WebsiteImage::getId, ids);
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return new WebsiteImageApiBriefListVO(this.listConvertApiBriefData(websiteImageList));
    }

    /**
     * 根据查询条件获取简略VO data list
     *
     * @param queryWrapper 查询条件
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefListVO getApiBriefListVO(Wrapper<WebsiteImage> queryWrapper) throws ManagerException {
        List<WebsiteImage> websiteImageList = this.list(queryWrapper);
        return new WebsiteImageApiBriefListVO(this.listConvertApiBriefData(websiteImageList));
    }

    /**
     * 根据对象list获取简略VO data list
     *
     * @param websiteImageList 对象list
     * @return 简略VO data list对象
     * @throws ManagerException 通用层异常
     */
    @Override
    public WebsiteImageApiBriefListVO getApiBriefListVO(List<WebsiteImage> websiteImageList) throws ManagerException {
        return new WebsiteImageApiBriefListVO(this.listConvertApiBriefData(websiteImageList));
    }
}